package cn.zcx;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Locale;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.02.17.11.24
 */
public class d1 {
    public static void main(String[] args) throws SQLException, FileNotFoundException {
        String path="d:/t.jpg";
        var file=new File(path);
        var fn=file.getName().toLowerCase();
        var is=new FileInputStream(file);
        System.out.println(is);
        var c= DriverManager.getConnection("jdbc:mysql://localhost:3305/t1","root","");
        System.out.println(c);
        var sql="insert into t1.du_file value(null,?,?)";
        var p=c.prepareStatement(sql);
        p.setString(1,fn);
        p.setBlob(2,is);
        var ok=p.executeUpdate();
        System.out.println(ok);
        if(ok>0){
            System.out.println("插入成功");
        }

    }
}
